package com.dyh.quickdemo.GoodsRules;

import java.util.Objects;
import java.util.function.Function;

/*
@Author=Joey Wheeler
@Date=2021/3/4 15:46
*/
public class ChainOp<T> {
    private final T val;
    private ChainOp(T val){
        this.val = val;
    }
    public static <T> ChainOp<T> from(T val){
        return new ChainOp<>(val);
    }

    public  <U> ChainOp<U> map(Function<? super T,? extends U> mapper){
        Objects.requireNonNull(mapper);
        return from(mapper.apply(this.val));
    }

    public T value(){
        return this.val;
    }

    public static void main(String[] args) {
        System.out.println(ChainOp.from("111").map(String::length).value());

    }
}
